<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <div class="contentsize">配套信息</div>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-form ref="form" :model="form" label-width="120px" :inline="true" size="mini">
                    <el-form-item label="区属名称:">
                        <div style="width: 170px">
                            <el-select v-model="form.qs" placeholder="请选择区属名称" clearable @change="onSearch">
                                <el-option v-for="item in qslist" :key="item.value" :label="item.label" :value="item.value"> </el-option>
                            </el-select>
                        </div>
                    </el-form-item>
                    <el-form-item label="产别类型:">
                        <div style="width: 170px">
                            <el-select v-model="form.cb" placeholder="请选择产别类型" clearable @change="onSearch">
                                <el-option v-for="item in cblist" :key="item.code" :label="item.name" :value="item.code"> </el-option>
                            </el-select>
                        </div>
                    </el-form-item>
                    <el-form-item label="档案编号:">
                        <div style="width: 170px">
                            <el-input v-model="form.dabh" placeholder="请输入档案编号" @keyup.enter.native="onSearch"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="土地使用权类型:">
                        <div style="width: 170px">
                            <el-input v-model="form.tdsyqlx" placeholder="请输入土地使用权类型" @keyup.enter.native="onSearch"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="建筑面积:">
                        <div style="width: 170px">
                            <el-col :span="11">
                                <el-input v-model="form.jzmja" @keyup.enter.native="onSearch"></el-input>
                            </el-col>
                            <el-col class="line" :span="2"><span style="font-size: 12px">至</span></el-col>
                            <el-col :span="11">
                                <el-input v-model="form.jzmjb" @keyup.enter.native="onSearch"></el-input>
                            </el-col>
                        </div>
                    </el-form-item>
                    <el-form-item label="房屋地址:">
                        <div style="width: 170px">
                            <el-input v-model="form.fwdz" placeholder="请输入房屋地址" @keyup.enter.native="onSearch"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="房产状态:">
                        <div style="width: 170px">
                            <el-select v-model="form.fczt" placeholder="请选择房产状态" clearable @change="onSearch">
                                <el-option v-for="item in fcztlist" :key="item.code" :label="item.name" :value="item.code"> </el-option>
                            </el-select>
                        </div>
                    </el-form-item>
                    <el-form-item label="房屋性质:">
                        <div style="width: 170px">
                            <el-select v-model="form.fwyt" placeholder="请选择房屋性质" clearable @change="onSearch">
                                <el-option v-for="item in fwytlist" :key="item.code" :label="item.name" :value="item.code"> </el-option>
                            </el-select>
                        </div>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSearch" icon="el-icon-search" class="searchcolor">查询</el-button>
                        <el-button @click="reSearch" icon="el-icon-refresh" class="searchcolor">重置</el-button>
                    </el-form-item>
                </el-form>
            </div>
            <el-table
                :data="tableData"
                style="width: 100%"
                :header-cell-style="tableHeaderColor"
                :row-style="tablerowColor"
                :row-class-name="tableRowClassName"
                :cell-style="tablecellColor"
                border
                :max-height="maxHeight"
            >
                <el-table-column prop="dabh" label="档案编号" align="center"> </el-table-column>
                <el-table-column prop="qs" label="区属" align="center" width="100"> </el-table-column>
                <el-table-column prop="fwdz" label="房屋地址" align="center" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="fwyt" label="房屋性质" align="center" width="100"> </el-table-column>
                <el-table-column prop="cb" label="产别" align="center" width="100"> </el-table-column>
                <el-table-column prop="zlc" label="总层数" align="center" width="80"> </el-table-column>
                <el-table-column prop="jzmj" label="建筑面积" align="center" width="100"> </el-table-column>
                <el-table-column prop="jizumj" label="计租面积" align="center" width="100"> </el-table-column>
                <el-table-column label="操作" width="100" align="center" fixed="right">
                    <template slot-scope="scope">
                        <el-button type="text" size="small" @click="gotodetail(scope.row.id)">详情</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination" style="float: right">
                <el-pagination
                    background
                    layout="total,sizes,prev, pager, next,jumper"
                    :total="total"
                    :current-page.sync="current"
                    :page-size="pageSize"
                    @current-change="handleCurrentChange"
                    :page-sizes="[10, 20, 30, 40, 50, 100]"
                    @size-change="handleSizeChange"
                >
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import { buildlist } from '@/api/index';
import valueList from '@/components/common/valueList.vue';
export default {
    name: 'dalist',
    data() {
        return {
            newPhonenum: {
                id: '',
                lxdh: ''
            }, //新的电话
            editdialog: false,
            dialogVisible: true,
            radio: 3,
            total: 0,
            current: 1,
            pageSize: 10,
            form: {
                cb: '',
                cqdw: '',
                create_name: '',
                create_name_id: '',
                create_time: '',
                current: 0,
                dabh: '',
                dscs: '',
                dxcs: '',
                fmjz: '',
                fmjzjb: '',
                wwbh: '',
                wwbhjb: '',
                fwdz: '',
                fwjg: '',
                fwyt: '',
                fzrq: '',
                id: '',
                jdrq: '',
                jzmj: '',
                jzmja: '',
                jzmjb: '',
                jznd: '',
                jzxs: '',
                note: '',
                pageSize: 10,
                qs: '',
                qzlx: '',
                status_code: 0,
                tdsyqlx: '',
                tdsyqmj: '',
                update_name: '',
                update_name_id: '',
                update_time: '',
                yz: '',
                zlc: '',
                zsbh: '',
                zsxyl: '',
                fczt: '1'
            },
            tableData: [],
            qslist: valueList.qslist,
            cqdwlist: valueList.cqdwlist, //产权单位
            fwytlist: valueList.fwytlist, //房屋性质
            cblist: valueList.cblist, //产别
            qzlxlist: valueList.qzlxlist, //权证类型
            tdsyqlxlist: valueList.tdsyqlxlist, //土地使用权类型
            sflist: valueList.sflist, //是否列表
            gfdwlist: valueList.gfdwlist, //管房单位
            fcztlist: valueList.fcztlist, //房产状态
            fmjzjblist: valueList.fmjzjblist, //风貌建筑级别
            wwbhjblist: valueList.wwbhjblist, //文物保护级别
            maxHeight: null
        };
    },
    components: {},
    computed: {
        // 判断变色
        getcolorred(htzt) {
            console.log(htzt);
            return (htzt) => {
                if (htzt == '正常') {
                    return { color: '#19BE6B', fontWeight: 700 };
                } else if (htzt == '已经到期') {
                    return { color: '#D9001B', fontWeight: 700 };
                } else if (htzt == '即将到期') {
                    return { color: '#FF9900', fontWeight: 700 };
                } else if (htzt == '未签合同') {
                    return { color: '#409ee1', fontWeight: 700 };
                }
            };
        }
    },
    methods: {
        // var data = datas.find((item) => item.id == "1"); 使用find方法找到数组中对应的对象
        // 列表样式
        tableHeaderColor({ row, column, rowIndex, columnIndex }) {
            if (rowIndex === 0) {
                return 'background:linear-gradient(to bottom, #008A94,#0ae2f2)!important;color:#ffffff;font-size:14px;';
            }
        },
        tablerowColor({ row, rowIndex }) {
            return 'height: 42px;font-size:14px;color:black';
        },
        tablecellColor() {
            return 'font-weight:700;color:#000000;border-color:#c0c0c0';
        },
        tableRowClassName({ row, rowIndex }) {
            if (rowIndex % 2 != 0) {
                return 'success-row'; //这是类名
            } else {
                return '';
            }
        },
        // 换页
        handleCurrentChange(val) {
            this.current = val;
            this.form.current = val;
            this.form.pageSize = this.pageSize;
            this.buildlist(this.form);
            console.log(val);
        },
        // 每页条数
        handleSizeChange(val) {
            this.current = 1;
            this.pageSize = val;
            this.form.pageSize = val;
            this.buildlist(this.form);
            console.log(val);
        },
        // 搜索
        onSearch() {
            this.current = 1;
            this.form.current = 1;
            this.buildlist(this.form);
            console.log('搜索');
        },
        // 重置
        reSearch() {
            this.current = 1;
            this.pageSize = 10;
            this.form = {
                cb: '',
                cqdw: '',
                create_name: '',
                create_name_id: '',
                create_time: '',
                current: 0,
                dabh: '',
                dscs: '',
                dxcs: '',
                fmjz: '',
                fmjzjb: '',
                wwbh: '',
                wwbhjb: '',
                fwdz: '',
                fwjg: '',
                fwyt: '',
                fzrq: '',
                id: '',
                jdrq: '',
                jzmj: '',
                jzmja: '',
                jzmjb: '',
                jznd: '',
                jzxs: '',
                note: '',
                pageSize: 10,
                qs: '',
                qzlx: '',
                status_code: 0,
                tdsyqlx: '',
                tdsyqmj: '',
                update_name: '',
                update_name_id: '',
                update_time: '',
                yz: '',
                zlc: '',
                zsbh: '',
                zsxyl: '',
                fczt: '1'
            };
            this.buildlist(this.form);
            console.log('搜索');
        },
        // 项目列表
        buildlist(data) {
            buildlist(data).then((res) => {
                if (res.code == 200) {
                    this.tableData = res.data.records;
                    this.total = res.data.total;
                    this.maxHeight = window.innerHeight - 440
                } else {
                    this.tableData = [];
                    this.total = 0;
                }
            });
        },
        // 编辑租金信息
        zjinfoupdate(data) {
            zjinfoupdate(data).then((res) => {
                if (res.code == 200) {
                    this.$message.success('修改成功！！！');
                } else {
                    this.$message.error('修改失败！！！');
                }
            });
        },
        // 跳转详情页
        gotodetail(e) {
            console.log('详情', e);
            this.$router.push({
                name: 'fwjgfjdetail',
                query: { id: e }
            });
        }
    },
    mounted() {
        this.$nextTick(() => {
            // window.innerHeight 浏览器窗口的可见高度，下面的 420 是除了table最大高度的剩余空间。
            this.maxHeight = window.innerHeight - 440;
        });
        this.buildlist(this.form);
    }
};
</script>

<style scoped>
/* 单选样式强制修改成纵向的*/
::v-deep .msgbox-card .el-radio {
    width: 90%;
    display: block;
    margin: 10px 0;
}
.container {
    /* height: calc(100vh - 260px); */
    overflow: hidden;
}

.crumbs {
    background-color: #fff;
    padding: 20px 20px;
}

.indexTitle {
    margin-bottom: 20px;
}

.contentsize {
    font-size: 18px;
    font-weight: 700;
}

.handle-box {
    overflow: hidden;
}

/* 新增按钮 */
.addcolor {
    margin-bottom: 10px;
}
</style>
<style>
.success-row {
    background-color: #eaf3fb !important;
}
</style>
